﻿using AutoMapper;
using Enferno.Public.Web.Models;
using Enferno.Public.Web.ViewModels;

namespace Enferno.Public.Web.Mappers.PromotionProfiles
{
    public class PromotionViewModelToPromotionModelProfile :
        PromotionBaseViewModelToPromotionBaseModelProfile<PromotionViewModel, PromotionModel, ProductFileModel>
    {
        
    }

    public class PromotionBaseViewModelToPromotionBaseModelProfile<TPromotionViewModel, TPromotionModel, TProductFileModel> : Profile
        where TPromotionViewModel: PromotionViewModel
        where TPromotionModel: PromotionBaseModel<TProductFileModel>
        where TProductFileModel: ProductFileModel
    {
        protected override void Configure()
        {
            Mapper.CreateMap<TPromotionViewModel, TPromotionModel>()
                .ForMember(to => to.AllowProductListing, opts => opts.Ignore())
                .ForMember(to => to.Images, opts => opts.Ignore())
                .ForMember(to => to.IsExcludedFromPriceCalculation, opts => opts.Ignore());
        }

        public override string ProfileName
        {
            get { return GetType().Name; }
        }
    }
}
